package cbfg.http.demo.wanandroid

import cbfg.http.annotation.*
import cbfg.http.demo.wanandroid.entity.Account
import cbfg.http.demo.wanandroid.entity.ArticleListEntity
import cbfg.http.demo.wanandroid.entity.BaseWanEntity
import cbfg.http.demo.wanandroid.entity.OfficialAccount
import cbfg.http.subscribe.Observable

/**
 * @author:  Tom Hawk
 * 添加时间: 2020/9/22 15:02
 * 功能描述:
 */
@HostTag(WanService.TAG)
interface WanService {
    companion object {
        const val TAG = "WanAndroid"
        const val URL = "https://www.wanandroid.com"
    }

    @POST("/user/register")
    @FormUrlEncoded
    fun register(
        @Field("username") username: String,
        @Field("password") password: String,
        @Field("repassword") repassword: String
    ): Observable<String>

    @POST("/user/login")
    @FormUrlEncoded
    fun login(
        @Field("username") username: String,
        @Field("password") password: String,
    ): Observable<String>

    @POST("/user/login")
    @FormUrlEncoded
    fun login(@Body account: Account): Observable<String>

    @GET("/wxarticle/chapters/json")
    fun getOfficialAccounts(): Observable<BaseWanEntity<List<OfficialAccount>>>

    @GET("/wxarticle/list/{accountId}/{pageNum}/json")
    fun getAccountArticles(
        @Path("accountId") accountId: String,
        @Path("pageNum") pageNum: String
    ): Observable<BaseWanEntity<ArticleListEntity>>

    @GET("/wxarticle/list/{accountId}/{pageNum}/json")
    fun getAccountArticles2(
        @Path("accountId") accountId: String,
        @Path("pageNum") pageNum: String
    ): Observable<String>
}